package com.jservice.framework.servlet;

import com.jfinal.handler.Handler;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

/**
 *
 * 仿照spring mvc，将request、response暂存到ThreadLocal
 * @author cwledit
 */
public class ServletContextHandler extends Handler {
	

	@Override
	public void handle(String target, HttpServletRequest request, HttpServletResponse response, boolean[] isHandled) {
		try {
			ServletContextHolderKit.set(new ServletContextHolder(request, response));
			next.handle(target, request, response, isHandled);
		} finally {
			ServletContextHolderKit.remove();
		}

	}
}
